package com.fdb.efp.flow.route.impl;

import com.fdb.efp.flow.route.AbstractRouteServicePluginExecutor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.alibaba.dubbo.rpc.service.GenericService;
import com.fdb.efp.flow.service.vo.BizFlowRouteVO;
import com.fdb.basic.framework.core.util.SpringContextUtils;
import com.fdb.basic.framework.core.util.StringUtil;

/**
 * 
 * 路由服务插件执行
 * 
 * @author Cytus_
 * @since 2018年5月24日 上午9:24:48
 * @version 1.0
 *
 */
@Deprecated
@Service("defaultRouteServicePluginExecutor")
public class DefaultRouteServicePluginExecutor extends AbstractRouteServicePluginExecutor {
	
	private static Logger logger = LoggerFactory.getLogger(DefaultRouteServicePluginExecutor.class);

	public boolean serviceCall(String serviceId, String serviceMethod, String g_bizSerno, String e_bizSerno) throws Exception {
	    
	    if (StringUtil.isEmpty(serviceId) || StringUtil.isEmpty(serviceMethod)) return true;
		
		logger.info("全局流水号："+ g_bizSerno +", 业务流水号："+ e_bizSerno +", 服务ID："+ serviceId +", 服务方法："+ serviceMethod +"调用开始......");
		boolean result = false;
		String[] paramTypes = {"java.lang.String", "java.lang.String"};
		Object[] params = {g_bizSerno, e_bizSerno};
		
		GenericService gs = SpringContextUtils.getBean("serviceId", GenericService.class);
		Object gsRtnObj = gs.$invoke(serviceMethod, paramTypes, params);
		if (gsRtnObj instanceof Boolean) {
			result = Boolean.valueOf(String.valueOf(gsRtnObj));
		}
		logger.info("全局流水号："+ g_bizSerno +", 业务流水号："+ e_bizSerno +", 服务ID："+ serviceId +", 服务方法："+ serviceMethod +"调用结束, 调用结果为"+ result);
		return result;
	}

    public boolean isDefault(BizFlowRouteVO routeVo) {
        return false;
    }

}
